/**
 * 
 */
package test;

import java.util.Arrays;

/**
 * @author Administrator
 *
 */
public class Rotate {
    public static int[][] rotateMatrix(int[][] mat, int n) {
        // write code here
        int[][] a  = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = mat[n-1-j][i];
            }
        }
        
        return a;
    }
    
    public static void main(String[] args) {
        
        int[][] a = new int[3][3]; 
        a[0][0] = 1;
        a[0][1] = 2;
        a[0][2] = 3;
        a[1][0] = 4;
        a[1][1] = 5;
        a[1][2] = 6;
        a[2][0] = 7;
        a[2][1] = 8;
        a[2][2] = 9;
       
        
         System.out.println(Arrays  .toString(rotateMatrix(a,3)));
          
          
      }
}
